home *** CD-ROM | disk | FTP | other *** search
/ MacFormat 1997 February / macformat-047.iso / Shareware Plus / Developers / DLOGManager 1.02 / Source Code / FirstWindow_v00.cp < prev    next >
Encoding:
Text File  |  1996-09-16  |  3.0 KB  |  180 lines  |  [TEXT/KAHL]

  1. /*****
  2.  *    FirstWindow_v00.c
  3.  *
  4.  *    Routines per la gestione della prima finestra di StandAlone.
  5.  *
  6.  *    11/11/94        Prima stesura (Francesco Cadili)
  7.  *
  8.  ****/
  9.  
  10.  
  11. /*****    Include standard        *****/
  12. #ifndef _H_Film
  13. #include "Film.h"
  14. #endif
  15. #include "FirstWindow_v00.h"
  16. #include "Error.h"
  17. #include "LeggiFilm_v04.h"
  18. #include "StrUtilities.h"
  19.  
  20. /*****    Define macro            *****/
  21.  
  22. /*****    Define valori            *****/
  23.  
  24. #pragma segment FirstWindow
  25.  
  26. /*****    Typedef globali            *****/
  27.  
  28. /*****    Funzioni esterne        *****/
  29.  
  30. /*****    Variabili esterne        *****/
  31.  
  32. /*****    Variabili globali        *****/
  33.  
  34. DialogPtr                FirstWnd;
  35. extern WindowPtr         frontmost;
  36. Boolean                    NuovoRecord;
  37.  
  38. /*****    Statiche globali        *****/
  39.  
  40. /*****    Function prototyping    *****/
  41. static void        ReleaseFirstWindowData(void);
  42.  
  43. /****
  44.  *    FirstWindow(theWPtr, event)
  45.  *
  46.  *    Gestisce la finestra di inserimento dello stile.
  47.  *
  48.  ****/
  49.  
  50. void    FirstWindow(void)
  51. {
  52.     EventRecord    event;
  53.  
  54. // case WOPEN:
  55.             
  56. #ifdef CONTROLLORISORSE
  57.     CaricaRisorsa('DLOG', FirstDLOG);
  58. #endif
  59.     frontmost = GetNewDialog(FirstDLOG, NULL, (WindowPtr)-1L);
  60.     if (frontmost == NULL)
  61.     {
  62.         SetErrorData(kErrRisorse, 0, "getnewdialog", "durante la lettura di una risorsa", "Errore in memoria");
  63.         ReleaseFirstWindowData();
  64.         return;
  65.     }
  66.  
  67.     SetWRefCon(frontmost, 0L);                    // devo settare il valore in qualche modo
  68.     FirstWnd = frontmost;
  69.     if (! Alloca_LeggiFilm(frontmost))
  70.     {
  71.         ReleaseFirstWindowData();
  72.         return;
  73.     }
  74.  
  75.     ShowWindow(frontmost);
  76. //    SelectWindow(frontmost);
  77.  
  78. /*    inizio Loop */
  79.  
  80.     do {
  81.         GetNextEvent (everyEvent, &event);
  82.     }
  83.     while(FirstWindow_Loop(FirstWnd, &event));
  84.  
  85. /* fine loop */
  86.     
  87. //    case WCLOSE:
  88.     ReleaseFirstWindowData();
  89.     if(frontmost)
  90.         DisposeDialog(frontmost);
  91.     frontmost = nil;
  92. }
  93. /* end FirstWindow */
  94.  
  95. /****
  96.  *    ReleaseFirstWindowData(void)
  97.  *
  98.  *    Effettua tutte le operazioni di rilascio relative alla prima finestra.
  99.  *
  100.  ****/
  101.  
  102. static void    ReleaseFirstWindowData(void)
  103. {
  104.     Dealloca_LeggiFilm();
  105.     DisplayErrorData();
  106.     ResetErrorData();
  107. }
  108. /* end ReleaseFirstWindowData */
  109.  
  110. /****
  111.  *    FirstWindow_Loop(theWPtr, event)
  112.  *
  113.  *    Gestisce la finestra di inserimento dello stile.
  114.  *
  115.  ****/
  116.  
  117. short        FirstWindow_Loop(WindowPtr    theWPtr, EventRecord    *myEvent)
  118. {
  119.     short        item, result;
  120.     
  121.     result = true;
  122.     if(theWPtr)
  123.     {
  124.         SetPort(theWPtr);
  125.         GlobalToLocal(&myEvent->where);
  126.     }
  127.  
  128.     FirstWindowCursor(theWPtr, myEvent->where);
  129.     FirstWindowIdle(theWPtr);
  130.  
  131.     switch(myEvent->what)
  132.     {
  133.         case updateEvt:
  134.             LeggiFilm_updateEvt();
  135.             break;
  136.  
  137.         case mouseDown:
  138.             LocalToGlobal(&myEvent->where);
  139.             /* prosegue */
  140.             
  141.         case keyDown:
  142.         case autoKey:        
  143.             item = FirstWindowKeyDown(theWPtr, myEvent);
  144.             switch(item)
  145.             {
  146.                 case ok:
  147.                     NuovoRecord = false;
  148.                     break;
  149.                     
  150.                 case cancel:
  151.                     result = false;
  152.                     break;
  153.  
  154.                 case w1tipoPopUpItem:
  155.                     //clickInPopUp(theWPtr, true);
  156.                     break;
  157.  
  158.                 case w1tokenItem:
  159.                     ClickInTokenItem(myEvent);
  160.                     break;
  161.                     
  162.                 case w1ricerca:
  163.                     if(! ClickInRicerca())
  164.                     {
  165.                         DisplayErrorData();
  166.                         ResetErrorData();
  167.                     }
  168.                     break;
  169.                     
  170.                 case w1nuovo:
  171.                     NuovoRecord = true;
  172.                     break;                    
  173.             }
  174.             break;
  175.     }
  176.     
  177.     return(result);
  178. }
  179. /* end FirstWindow_Loop */
  180.